package main

import (
	"com.haojuetrace/actualCombat/common"
	"com.haojuetrace/actualCombat/configs"
	"com.haojuetrace/actualCombat/route"
	"fmt"
	"github.com/gin-gonic/gin"
	_ "github.com/go-sql-driver/mysql"
	"github.com/spf13/viper"
)

func main() {
	configs.InitConf()        //初始化配置文件
	_, err := common.InitDb() // 初始化数据库
	if err != nil {
		fmt.Println("init db failed err:", err)
		return
	}
	r := gin.Default()
	r = route.CollectRoute(r)
	port := viper.GetString("server.port")
	if port != "" {
		port = ":" + port
	} else {
		port = ":8080" //
	}
	r.Run(port) //启动web服务
}
